﻿@{
    ViewBag.Title = "订单";
    Layout = "~/Views/Shared/_MyLayout.cshtml";
}

@section head{
    <link rel="stylesheet" type="text/css" href="~/Content/WxPage.css?d=@DateTime.Now" />
    @Scripts.Render("~/bundles/jquery")
    <script src="~/Scripts/bootstrap.js"></script>
}

@*<div style="height:155px;padding-top:10px;position:relative;">
    <div style="background:url(../../Content/IMG/member_yellow.png)" class="menber_card">
        <div class="m_c_head" style="float:left;">

            <img src="@ViewBag.HeadImgUrl"/>
        </div>
        <div class="m_c_aside" style="float:right;">
            <ul class="member_info">

                <li class="num">NO.@ViewBag.MemberNo</li>
                <li class="name">@ViewBag.UserName</li>
                <li class="leave">普通会员</li>
            </ul>
        </div>
    </div>
</div>*@
<div style="position:relative;margin-top:40px;margin-bottom:20px;width:100%;height:195px;background-image:url('/Content/IMG/03.logo.png');background-size:100% 100%;">
    <div style="position:absolute;left:15%;bottom:16%; width:50%;height:18px;background-color:transparent;">
        <p style="text-align:left;line-height:100%;font-size:16px;font-family:'Microsoft YaHei','微软雅黑';color:rgb(192,160,98)">会员卡号&nbsp;&nbsp;&nbsp; @ViewBag.MemberNo.ToString().PadLeft(7, '0')</p>
    </div>
    <div style="position:absolute;right:10%;top:10%;width:10%;height:18px;background-color:transparent;" onclick="GoUserEdit()">
        <p style="text-align:left;line-height:100%;font-size:16px;font-family:'Microsoft YaHei','微软雅黑';color:rgb(192,160,98)">编辑</p>
    </div>
</div>
<div style="width:100%;height:29px;background-image:url('/Content/IMG/03.biaoti.png');background-size:100% 100%;">
</div>

@*以下是订单信息*@
@for (int i = 0; i < ViewBag.OrderList.Count; i++)
{
    <div style="clear:both;position:relative;margin-top:20px;width:100%;height:29px;background-image:url('/Content/IMG/03.menudown.png');background-size:100% 100%;" onclick="changStretch('NO_@ViewBag.OrderList[i]["ZZOrderId"]',this)">
        <p style="position:absolute;display:block;line-height:29px;left:19%;font-size:14px;font-family:'Microsoft YaHei','微软雅黑';">订单编号 NO.@ViewBag.OrderList[i]["ZZOrderId"]</p>
    </div>
    if (ViewBag.OrderList[i]["state"].ToString() == "0")
    {
        <div style="height:auto;position:relative;width:100%;display:block;" id="NO_@ViewBag.OrderList[i]["ZZOrderId"]">
            <p class="orderdetailp1">订单时间:&nbsp;&nbsp;@ViewBag.OrderList[i]["OrderTime"]</p>
            <p class="orderdetailp2">酒店地址:&nbsp;&nbsp;@ViewBag.OrderList[i]["HotelName"]</p>
            <p class="orderdetailp2">房型:&nbsp;&nbsp; @ViewBag.OrderList[i]["RoomTypeName"]</p>
            <p class="orderdetailp2">入住时间:&nbsp;&nbsp;@ViewBag.OrderList[i]["EnterTime"]</p>
            <p class="orderdetailp2">离店时间:&nbsp;&nbsp;@ViewBag.OrderList[i]["LeaveTime"]</p>
            <p class="orderdetailp2">一共 @ViewBag.OrderList[i]["DiffDay"] 晚&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;房间数量:&nbsp;&nbsp;@ViewBag.OrderList[i]["RoomNum"]</p>
            <p class="orderdetailp2">联系电话&nbsp;&nbsp;&nbsp;&nbsp;@ViewBag.OrderList[i]["PhoneNum"]</p>
            <p class="orderdetailp3">费用共计:&nbsp;&nbsp;&nbsp;@ViewBag.OrderList[i]["TotalPrice"]RMB&nbsp;&nbsp;&nbsp;支付状态:&nbsp;&nbsp;@ViewBag.OrderList[i]["Orderstate"] </p>
            <div style="float:right;margin-right:10%;margin-left:10px;margin-bottom:20px;width:84px;height:25px;background-image:url('/Content/IMG/03.cancelorder.png');background-size:100% 100%;" onclick="CancelOrder(@ViewBag.OrderList[i]["HotelId"],@ViewBag.OrderList[i]["ZZOrderId"])">
                @*<p style="line-height:30px;font-size:25px;text-align:center;">取消订单</p>*@
            </div>
            <div style="float:right;margin-bottom:20px;width:84px;height:25px;background-image:url('/Content/IMG/03.paybtn.png');background-size:100% 100%;" onclick="WxPay(@ViewBag.OrderList[i]["ZZOrderId"])">
                @*<p style="line-height:30px;font-size:25px;text-align:center;">微信付款</p>*@
            </div>

        </div>
    }
    else
    {
        <div style="height:auto;position:relative;width:100%;display:none;" id="NO_@ViewBag.OrderList[i]["ZZOrderId"]">
            <p class="orderdetailp1">订单时间:&nbsp;&nbsp;@ViewBag.OrderList[i]["OrderTime"]</p>
            <p class="orderdetailp2">酒店地址:&nbsp;&nbsp;@ViewBag.OrderList[i]["HotelName"]</p>
            <p class="orderdetailp2">房型:&nbsp;&nbsp; @ViewBag.OrderList[i]["RoomTypeName"]</p>
            <p class="orderdetailp2">入住时间:&nbsp;&nbsp;@ViewBag.OrderList[i]["EnterTime"]</p>
            <p class="orderdetailp2">离店时间:&nbsp;&nbsp;@ViewBag.OrderList[i]["LeaveTime"]</p>
            <p class="orderdetailp2">一共 @ViewBag.OrderList[i]["DiffDay"] 晚&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;房间数量:&nbsp;&nbsp;@ViewBag.OrderList[i]["RoomNum"]</p>
            <p class="orderdetailp2">联系电话&nbsp;&nbsp;&nbsp;&nbsp;@ViewBag.OrderList[i]["PhoneNum"]</p>
            <p class="orderdetailp3">费用共计:&nbsp;&nbsp;&nbsp;@ViewBag.OrderList[i]["TotalPrice"]RMB&nbsp;&nbsp;&nbsp;支付状态:&nbsp;&nbsp;@ViewBag.OrderList[i]["Orderstate"] </p>
        </div>
    }


}

<div style="clear:both;height:10%;width:100%;"></div>


@*<div class="RORoomNum">
    <div style="float:left;width:50px;margin-left:5px;">
        <img src="~/Content/IMG/OrderList.png" style="width:auto;height:38px;" />
    </div>
    <div style="height:30px;background:transparent;width:230px;margin-top:2px;margin-bottom:5px;" onclick="window.location.href='/WxPage/OrderList'">
        <p style="margin:0;line-height:35px;font-size:20px;">我的订单</p>
    </div>
    <div style="position:absolute;right:10px;">
        <img src="~/Content/IMG/ToRight.png" style="width:auto;height:30px;" />
    </div>
</div>*@




<div id="menu" class="Wx_BottomMenu">
<div id="HomePage" class="subMenu" onclick="JavaScript:window.location.href='/WxPage/MainView'">
    <p style="display:table-cell;vertical-align:middle;margin:0px;font-family:'Microsoft YaHei','微软雅黑';font-size:16px;color:rgb(127,127,127);">首&nbsp;&nbsp;页</p>
</div>
<div id="Rent" class="subMenu" style="border-left-width:1px;width:34%;" onclick="JavaScript:window.location.href='/WxPage/Index'">
    <p style="display:table-cell;vertical-align:middle;margin:0px;font-family:'Microsoft YaHei','微软雅黑';font-size:16px;color:rgb(127,127,127);">预&nbsp;&nbsp;订</p>
</div>
<div id="Mine" class="subMenu" style="border-right-width:0px;border-left-width:1px;" onclick="JavaScript:window.location.href='/WxPage/Mine'">
    <p style="display:table-cell;vertical-align:middle;margin:0px;font-family:'Microsoft YaHei','微软雅黑';font-size:16px;color:rgb(127,127,127);">微&nbsp;&nbsp;信&nbsp;&nbsp;会&nbsp;&nbsp;员</p>
</div>
</div>

@*<div id="menu" class="Wx_BottomMenu">
    <div id="HomePage" class="subMenu" onclick="window.location.href='/WxPage/Index'">
        <button type="button" class="btn btn-primary" style="width:100%;height:100%;font-size:20px;">首页</button>
    </div>
    <div id="Rent" class="subMenu">
        <button type="button" class="btn btn-success" style="width:100%;height:100%;font-size:20px;">预定</button>
    </div>
    <div id="Mine" class="subMenu" onclick="window.location.href='/WxPage/Mine'">
        <button type="button" class="btn btn-info" style="width:100%;height:100%;font-size:20px;">我的</button>
    </div>
</div>*@

<script type="text/javascript">
    $(document).ready(function () {
        $("body").css("background-color", "rgb(255,255,245)");
        var screenHeight = document.documentElement.clientHeight;
        var screenWidth = document.documentElement.clientWidth;
        var body = document.getElementById('body');
        body.style.width = screenWidth + "px";
        body.style.height = screenHeight + "px";


    });
    window.onload = function () {
        if ("@ViewBag.PayImme.ToString()" == "yes") {
            WxPay("@ViewBag.ZZOrderId.ToString()");

            //alert("aaaaaaa");
        }
    }

</script>
<script type="text/javascript">
/*在下小本生意，走的正常付款流程，
后台已接收微信服务端转账消息验证XML，作为支付凭证，
请黑客大牛不要来破解我，在此谢过！！！*/

    var wxJsApiParam = "";

    function jsApiCall() {
        WeixinJSBridge.invoke(
            'getBrandWCPayRequest',
            $.parseJSON(wxJsApiParam),//josn串
            function (res) {
                WeixinJSBridge.log(res.err_msg);
                if (res.err_msg.indexOf("ok")) {
                    window.location.href = "/WxPage/Mine";
                }
                //alert(res.err_code);
                //alert(res.err_code + " ;" + res.err_desc + " ;" + res.err_msg);
            }
        );
    }
    function callpay() {
        if (typeof WeixinJSBridge == "undefined") {
            if (document.addEventListener) {
                document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
            } else if (document.attachEvent) {
                document.attachEvent('WeixinJSBridgeReady', jsApiCall);
                document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
            }
        } else {
            jsApiCall();
        }
    }

    function CancelOrder(hotelId, OrderId) {
        $.ajax({
            type: "POST",
            url: "/WxPage/CancelOrder",
            async: false,
            data: { "OrderId": OrderId, "hotelId": hotelId },
            success: function (msg) {
                if (msg == 1) {
                    //正确返回，执行操作
                    top.location = '/WxPage/Mine';
                } else {
                    alert("订单取消失败，请联系酒店前台");
                    return;
                }
            }
        });
    }

    function WxPay(ZZOrderId) {
        $.ajax({
            type: "POST",
            url: "/WxPage/WxPay",
            async: false,
            data: { "ZZOrderId": ZZOrderId },
            success: function (msg) {
                if (msg.err == "ok") {
                    //正确返回，执行操作
                    wxJsApiParam = msg.Param;
                    callpay();

                } else if (msg.err == "NoCookies") {
                    top.location = '/WxPage/Index';
                } else if (msg.err == "errId") {
                    alert("用户错误，请重新登陆");
                    top.location = '/WxPage/Register';
                } else if (msg.err == 'errOrderId') {
                    alert("订单号错误，不要试图错误提交,哥在后台做了验证的");
                    top.location = '/WxPage/Index';
                }
                else {
                    alert("订单提交失败，请联系酒店前台" + mes.err);
                    return;
                }
            }
        });
    }

    function changStretch(domid, listdom) {
        var currentstate = $("#" + domid).css("display");
        if (currentstate == "none") {
            $("#" + domid).css("display", "block");
            $(listdom).css("background-image", "url('/Content/IMG/03.menuup.png')");
        } else if (currentstate == "block") {
            $("#" + domid).css("display", "none");
            $(listdom).css("background-image", "url('/Content/IMG/03.menudown.png')");
        }


    }

    function GoUserEdit() {
        window.location.href = "/WxPage/UserEdit";
    }



</script>
